using MicroMsg.UI.Page;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class SelectCountryItem : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		public static DependencyProperty ListItemProperty = DependencyProperty.Register("ItemObject", typeof(string), typeof(SelectCountryItem), new PropertyMetadata(null, new PropertyChangedCallback(SelectCountryItem.OnItemPropertyChanged)));
		private static SelectCountryItem sSelectedItem = null;
		internal Button btnLayoutRoot;
		internal Grid LayoutRoot;
		internal DynamicTextBlock txtAreaName;
		private bool _contentLoaded;
		public event SelectCountryItem.ListItemClick ItemClick;
		public string ItemObject
		{
			get
			{
				return (string)base.GetValue(SelectCountryItem.ListItemProperty);
			}
			set
			{
				base.SetValue(SelectCountryItem.ListItemProperty, value);
			}
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == SelectCountryItem.ListItemProperty)
			{
				(dependencyObject_0 as SelectCountryItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		public SelectCountryItem()
		{
			this.InitializeComponent();
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_NewValue() is string)
			{
				string strCountry = dependencyPropertyChangedEventArgs_0.get_NewValue() as string;
				this.refresh(strCountry);
			}
		}
		private void refresh(string strCountry)
		{
			if (strCountry == null)
			{
				return;
			}
			this.txtAreaName.Text = strCountry;
			if (strCountry.Equals(SelectCountryPage.sStrSelectedCountry))
			{
				this.txtAreaName.set_Foreground(R.theme.COMMON_BRUSH);
				if (SelectCountryItem.sSelectedItem != null)
				{
					SelectCountryItem.sSelectedItem.txtAreaName.set_Foreground(R.theme.LISTA_NAME_WORD_BRUSH);
				}
				SelectCountryItem.sSelectedItem = this;
				return;
			}
			if (SelectCountryItem.sSelectedItem == this)
			{
				SelectCountryItem.sSelectedItem = null;
			}
			this.txtAreaName.set_Foreground(R.theme.LISTA_NAME_WORD_BRUSH);
		}
		private void btnLayoutRoot_Click(object sender, RoutedEventArgs e)
		{
			if (this.ItemClick != null)
			{
				SelectCountryPage.sStrSelectedCountry = this.ItemObject.ToString();
				this.refresh(this.ItemObject);
				this.ItemClick(this, this.ItemObject);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Setting/SelectCountryItem.xaml", 2));
			this.btnLayoutRoot = (Button)base.FindName("btnLayoutRoot");
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.txtAreaName = (DynamicTextBlock)base.FindName("txtAreaName");
		}
	}
}
